package com.wyl.niupi.config;

import com.wyl.niupi.config.Vo.FileSystemConfig;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * 自定义配置类，可以通过注入NiupiConfig或者使用静态变量获取配置信息
 * @author 吴宇亮 on 2020/11/23 17:08
 */
@ConfigurationProperties(prefix = "niupi-config")
@Configuration
public class NiupiConfig implements InitializingBean {

    private FileSystemConfig fileSystem;

    @Override
    public void afterPropertiesSet() {
        FileSystemConfig.IP = this.fileSystem.getIp();
        FileSystemConfig.PORT = this.fileSystem.getPort();
    }

    public FileSystemConfig getFileSystem() {
        return fileSystem;
    }

    public void setFileSystem(FileSystemConfig fileSystem) {
        this.fileSystem = fileSystem;
    }
}
